﻿using System;
using System.Collections.Generic;
using Gameplay.PVE.Utils;
using UnityEngine;
using XLua;
using Yoozoo.Framework.Core;

namespace Gameplay.PVE.Survivor
{
    public class ElementConfig
    {
        public int id;
        public int main_type;
        public int sub_type;
        public float value;
        public float duration;
        public int duration_effect;
        public int hit_effect;
        public List<int> extra_param;
        public float knockback_value;
        public int conflict;
        public List<Vector2Int> conflict_layer_element;
        public List<Vector2Int> clear_effect;
        public int group;
        public int conflict_value;
        public float trigger_interval;
        public int trigger_effect;
    }

    public partial class BattleConfigManager
    {
        private Dictionary<int, ElementConfig> elementMap;

        public ElementConfig GetElementConfig(int id)
        {
            if (elementMap.TryGetValue(id, out var config))
            {
                return config;
            }

            UnityEngine.Debug.LogError("元素配表不存在id:" + id);
            return null;
        }

        public static void PreloadElementConfig(LuaTable table)
        {
            PveUtils.PreloadRpgConfig(table, ref Instance.elementMap);
        }
    }
}